//JavaScript字符串去空格
String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
//JavaScript字符串广义长度：含汉字长度判断
String.prototype.wlength = function() {
	var len = (this.match(/[^ -~]/g)==null) ? this.length:
		this.length + this.match(/[^ -~]/g).length;
	return len;
}
//检查From数据
function check_reg_from(){
	var reg_form = document.reg_form;//注册表单
	var xm = reg_form.xm.value.trim();
	var dlmc = reg_form.dlmc.value.trim();
	var dlmm = reg_form.dlmm.value;
	var dlmm2 = reg_form.dlmm2.value;
	var dzyx = reg_form.dzyx.value.trim();
	if(xm==""){
		alert("请输入姓名!");return false;
	}
	if(xm.wlength()>50){
		alert("请缩短姓名输入长度!");return false;
	}
	if(dlmc==""){
		alert("请输入登录名!");return false;
	}
	if(dlmc.match(/[^ -~]/g)!=null){
		alert("登录名含有不支持字符,请输入字母或数字!");return false;
	}
	if(dlmc.length>50){
		alert("请减少登录名字符!");return false;
	}
	if(dlmm==""){
		alert("请输入密码!");return false;
	}
	if(dlmm!=dlmm2){
		alert("请核对密码!");return false;
	}
	if(dzyx==""){
		alert("请输入邮箱地址!");return false;
	}
	if(!isEmail(dzyx)){
		alert("请输入正确的邮箱地址!");return false;
	}
	return true;
}

//验证邮件地址
function isEmail(str){
    var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
    return reg.test(str);
}

function return_home(){
	window.location.href=sys_ctx+"/index.jsp";
}